FROM centos:6
MAINTAINER Brick Yang <brick.yang@printfxxx.com>

ARG YUM_MIRROR_URL=vault.centos.org

RUN cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.orig
RUN sed -i -e '/repo=centosplus/{n;n;n;s|enabled=0|enabled=1|}' /etc/yum.repos.d/CentOS-Base.repo
RUN sed -i -e 's|^mirrorlist=|#mirrorlist=|g' -e "s|^#baseurl=http://mirror.centos.org/centos/\$releasever|baseurl=http://$YUM_MIRROR_URL/6.10|g" \
	/etc/yum.repos.d/CentOS-Base.repo
RUN yum -y install "http://archives.fedoraproject.org/pub/archive/epel/6/`uname -m`/epel-release-6-8.noarch.rpm" && yum -y update
RUN yum -y install sudo
RUN yum -y reinstall glibc-common
RUN localedef -c -i en_US -f UTF-8 en_US.UTF-8
RUN echo 'LANG=en_US.UTF-8' > /etc/sysconfig/i18n
ENV LANG en_US.UTF-8
RUN passwd -d root

RUN yum -y install openssh-server vim x11vnc xorg-x11-server-Xvfb
RUN yum -y groupinstall Desktop Fonts
RUN yum -y install glibc.i686 libgcc.i686 libstdc++.i686 libXpm.i686 libXp.i686		\
	libXmu.i686 libuuid.i686 libxcb.i686 libXdamage.i686 libXtst.i686 libXt.i686	\
	PackageKit-gtk-module.i686 gtk2.i686 libcanberra-gtk2.i686 bc firefox xulrunner
RUN echo 'UseDNS no' >> /etc/ssh/sshd_config

ADD myvnc /etc/rc.d/init.d/myvnc
RUN chmod a+x /etc/rc.d/init.d/myvnc
ADD myvnc.sh /usr/local/bin/myvnc.sh
RUN chmod a+x /usr/local/bin/myvnc.sh
ADD startup.sh /usr/local/bin/startup.sh
RUN chmod a+x /usr/local/bin/startup.sh
ADD init.sh /usr/local/bin/init.sh
RUN chmod a+x /usr/local/bin/init.sh

ENTRYPOINT ["/usr/local/bin/startup.sh"]

EXPOSE 22
EXPOSE 5900
